<!--
 * @FilePath     : /study_code/vue/created.html
 * @Description  : created 钩子
 * @Date         : 2025-05-02 07:38:37
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-02 07:43:57
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app" v-clock></div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      // 自定义组件
      const myComponent = {
        data: function () {
          return {}
        },
        props: [],
        template: ``,
        methods: {},
      }

      var app = new Vue({
        el: '#app',
        data: function () {
          return {
            count: 2,
          }
        },
        computed: {
          longCount() {
            return (this.count += 3)
          },
        },
        methods: {
          getMsg() {
            console.log('获取信息')
          },
        },

        /**
         * @brief: 在 实例创建完成后 被立即同步调用的钩子函数。
         * ! beforeCreate ~ created 之间做了： 数据初始化 (inject/provide、props、methods、data、computed、watch)
         * @return {*}
         */
        created() {
          console.log('----------------------------created')
          console.log('1 访问 data', this.count) // '1 访问 data' 2
          console.log('2 访问 computed', this.longCount) // '2 访问 computed' 5
          this.getMsg() // 控制台输出 '获取信息'
          console.log('3 访问 $el', this.$el) // '3 访问 $el' undefined
        },
      })
    </script>
  </body>
</html>
